<%= render(:partial => "shared/flash_message") %>
<%= render :partial => "shared/config_save_actions", :locals => {:scope => {}} -%>
<%= form_for(scope[:material],
            :as => :material,
            :url => scope[:url],
            :html => {:method => scope[:method],
                      :onsubmit => "return AjaxForm.jquery_ajax_submit(this);",
                      :class => "popup_form"}) do |f| %>

    <%= md5_field %>
    <%= current_tab_field("materials") -%>
    <%= hidden_field_tag :material_type, scope[:material].getType() %>
    <div class="form_content change_materials">
        <%= render :partial => "admin/shared/global_errors.html", :locals => {:scope => {}} -%>
        <div class="fieldset">
            <%= render :partial => 'admin/materials/shared/material_name', :locals => {:scope => {:form => f}} %>
            <div class="form_item">
                <div class="form_item_block required">
                    <%= required_label(f, com.thoughtworks.go.config.materials.git.GitMaterialConfig::URL, 'URL') -%>
                    <%= f.text_field com.thoughtworks.go.config.materials.git.GitMaterialConfig::URL, {:class => "form_input url", :id => nil} -%>
                    <%= error_message_on(scope[:material], com.thoughtworks.go.config.materials.git.GitMaterialConfig::URL, :css_class => "form_error") %>
                </div>

                <div class="form_item_block">
                  <label>Username</label>
                  <%= f.text_field com.thoughtworks.go.config.materials.svn.SvnMaterialConfig::USERNAME, {:class => "form_input username", :id => nil} -%>
                  <%= error_message_on(scope[:material], com.thoughtworks.go.config.materials.svn.SvnMaterialConfig::USERNAME, :css_class => "form_error") %>
                </div>


                <% if scope[:edit_mode] %>
                  <%= render :partial => 'admin/materials/shared/password', :locals => {:scope => {:form => f}} %>
                <% else %>
                  <%= render :partial => 'admin/materials/shared/plain_password', :locals => {:scope => {:form => f}} %>
                <% end %>

                <%= render :partial => "admin/materials/shared/options", :locals => {:scope => {:form => f}} %>

                <div class="form_item_block">
                    <label>Branch</label>
                    <%= f.text_field com.thoughtworks.go.config.materials.git.GitMaterialConfig::BRANCH, {:class => "form_input branch", :id => nil} -%>
                    <%= error_message_on(scope[:material], com.thoughtworks.go.config.materials.git.GitMaterialConfig::BRANCH, :css_class => "form_error") %>
                </div>

                <%= render :partial => 'admin/materials/shared/dest_folder', :locals => {:scope => {:form => f}} %>

                <div class="form_item_block checkbox_row material_options">
                  <%= f.check_box(com.thoughtworks.go.config.materials.git.GitMaterialConfig::SHALLOW_CLONE, {:class => "form_input"}, "true") -%>
                  <%= f.label(com.thoughtworks.go.config.materials.git.GitMaterialConfig::SHALLOW_CLONE, 'Shallow clone (recommended for large repositories)') %>
                  <%= error_message_on(f.object, com.thoughtworks.go.config.materials.git.GitMaterialConfig::SHALLOW_CLONE, :css_class => "form_error") %>
                </div>

                <%= render :partial => 'admin/materials/shared/check_connection', :locals => {:scope => {:url => ".url", :type => "git", :branch => ".branch", :username => ".username", :password => '.password', :encrypted_password => '.encrypted_password', :password_changed => ".password_changed"}} %>
                <div class="clear"></div>
            </div>
            <%= render :partial => 'shared/form_required_message.html', :locals => {:scope => {}} %>
        </div>
        <%= render :partial => "admin/materials/shared/filter", :locals => {:scope => {:form => f}} %>
    </div>

    <%= render :partial => "shared/form_buttons.html", :locals => {:scope => {:submit_label => scope[:submit_label]}} unless scope[:read_only_page] %>
    <%= render :partial => 'shared/convert_tool_tips.html', :locals => {:scope => {}} %>
<% end %>
